    //
//  PopCategoryVC_iPad.m
//  WRY
//
//  Created by zhong sckj on 10-11-8.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "PopCategoryVC_iPad.h"
#import "RootVC_iPad.h"
#import "StaticVariable.h"
extern NSString *namecode;
extern NSString *nameStr;

@implementation PopCategoryVC_iPad
@synthesize categoryTblView,rootVc;
@synthesize dataArray;

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	NSString *filePath=[[NSBundle mainBundle]pathForResource:@"PsLevelData" ofType:@"plist"];
	NSMutableArray *array=[[NSMutableArray alloc]initWithContentsOfFile:filePath];
	self.dataArray=array;
	[array release];
	UIBarButtonItem *backButton=[[UIBarButtonItem alloc]initWithTitle:@"返回" 
																style:UIBarButtonItemStyleBordered 
															   target:self action:@selector(backAction:)];
	self.navigationItem.leftBarButtonItem=backButton;
	[backButton release];
}

-(void)backAction:(id)sender
{
	[rootVc.popController dismissPopoverAnimated:YES];
}
#pragma mark UITableViewDelegate & DataSource
- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section
{
	
	return [dataArray count]>0?[dataArray count]:1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
	static NSString *Identifier_ipad = @"StaticcategoryCell_iPad";
	UITableViewCell *cell=[self.categoryTblView dequeueReusableCellWithIdentifier:Identifier_ipad];
	if(cell == nil) {
		cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault 
								   reuseIdentifier:Identifier_ipad];
	}
	if ([dataArray count]>0)
	{
		NSDictionary *dir=[dataArray objectAtIndex:indexPath.row];
		NSString  *categoryName = [dir objectForKey:@"title"];
		cell.textLabel.text=categoryName;
		
	}
	else {
		cell.textLabel.text =@"没有记录";
		cell.selectionStyle=UITableViewCellSelectionStyleNone;
	}
 	return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
	if ([dataArray count]>0) {
		NSDictionary *dir=[dataArray objectAtIndex:indexPath.row];
		
		NSString *key=[dir objectForKey:@"title"];
		NSString *value=[dir objectForKey:key];
		nameStr=key;//编码名称
		namecode=value;//编码
		[rootVc addEnterpriseVC:3000 enterType:@""];
		[rootVc.popController dismissPopoverAnimated:YES];
	}	
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Overriden to allow any orientation.
    return YES;
}


- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}


- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
	[dataArray release];
	[rootVc release];
	[categoryTblView release];
    [super dealloc];
}


@end
